﻿using AutoMapper;
using Rbac.Contracts.DTO.InPut;
using Rbac.Contracts.DTO.OutPut;
using Rbac.Domain.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rbac.Contracts
{
	/// <summary>
	/// 将实体类与DTO类建立映射关系
	/// </summary>
	public class RbacProfile:Profile
	{
		public RbacProfile()
		{
			//将User类与UserOutPut映射上
			CreateMap<User, UserOutPut>();
			CreateMap<Role, RoleOutPut>();
			CreateMap<RoleInput, Role>();
			CreateMap<Permission, PermissionOutPut>();
			CreateMap<PermissionInPut, Permission>();
			//将permission中的id字段映射至permissionDTO中的PermissionId
			CreateMap<Permission, PermissionDTO>()
				.ForMember(c=>c.PermissionId,opt=>opt.MapFrom(src=>src.PermissionId));
		}
	}
}
